package com.example.pc.greenplants.Personal;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.pc.greenplants.Personal.Personal;
import com.example.pc.greenplants.R;

import java.util.List;

public class PersonalAdapter  extends ArrayAdapter<Personal> {
  private  int resourceId;
  public PersonalAdapter(Context context, int textViewrRsourceId, List<Personal> objects){
      super(context,textViewrRsourceId,objects);
      resourceId=textViewrRsourceId;
  }
  public View getView(int position, View convertView, ViewGroup parent){
      Personal personal=getItem(position);//获取当前的personal实例
       View view= LayoutInflater.from(getContext()).inflate(resourceId,parent,false);
      ImageView personalImage=(ImageView)view.findViewById(R.id.personal_image);
      TextView personalName=(TextView)view.findViewById(R.id.personal_name);
      personalImage.setImageResource(personal.getImageId());
      personalName.setText(personal.getName());
      return view;
  }
}
